package com.itWaiLong.Controller.group;

import com.itWaiLong.Dao.group_project;
import com.itWaiLong.Result.Result;
import com.itWaiLong.Service.GroupProjectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/select")
public class selectProjectController {

    @Autowired
    private GroupProjectService groupProjectService;

    /**
     * 通过项目id查询项目
     * @param projectId
     * @return
     */
    @GetMapping("/selectProjectById")
    public Result<group_project> selectProjectById(@RequestParam int projectId) {
        log.info("项目id：{}", projectId);
        group_project groupProject = groupProjectService.selectProjectById(projectId);
        return Result.success(groupProject);
    }

    /**
     * 查询团队所有项目
     * @param groupName
     * @return
     */
    @GetMapping("/selectAllProject")
    public Result<List<group_project>> selectAllProject(@RequestParam String groupName) {
        log.info("团队名称：{}", groupName);
        List<group_project> groupProjects = groupProjectService.selectAllProject(groupName);
        return Result.success(groupProjects);
    }
}
